import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution763 {
    public List<Integer> partitionLabels(String s) {
        int[] g=new int[26];
        Arrays.fill(g,-1);
        for (int i=0;i<s.length();i++) {
            char c=s.charAt(i);
            g[c-'a']=i;
        }
        List<Integer> list=new ArrayList<>();
        int t=0,dis,last=0;
        int ans=0;
        while (t<s.length()){
            ans++;
            dis=g[s.charAt(t)-'a'];
            while (t<s.length() && t<=dis){
                dis=Math.max(g[s.charAt(t)-'a'],dis);
                t++;
            }
            list.add(t-last);
            last=t;
        }
        return list;
    }

    public static void main(String[] args) {
        System.out.println(new Solution763().partitionLabels("ababcbacadefegdehijhklij"));
    }
}
